home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / c_scripts / ppscan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-11  |  2.8 KB  |  111 lines

  1. /*
  2. Web proxy port scanner beta v1.1
  3.  
  4. to compile:~$ gcc ppscan.c -o ppscan
  5. to use: ./ppscan <proxy> <port> <target> <start_port> <stop_port>
  6. (i.e. ./ppscan lameproxy.com 1234 antionline.com 1 1024 )
  7.  
  8. If those two lines are to hard for you, you should not be using it..
  9.  
  10. This code lets you port scan anonymously, by using a proxy server
  11. to bounce off of. If the proxy server connects to the host port, it
  12. returns a 200 OK, like if there was a web server there, but then
  13. disconnects. The logs of the system scanned will show the proxy box and
  14. not the real person doing the scan.
  15.  
  16. Coded by Bronc Buster Dec 1998
  17. Updated Jan 1999
  18.  
  19. Thanks to: horizon of Rhino9, r4lph of b4b0 and argv for the help 
  20.            getting this to work(?)
  21.  
  22. [gH] - aka gLoBaL h3Ll are lame kode kiddies with no skills, they all need
  23. to die miserable deaths....
  24.  
  25. */
  26.  
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <netinet/in.h>
  30. #include <unistd.h>
  31. #include <sys/types.h>
  32. #include <sys/socket.h>
  33. #include <netdb.h>
  34. #include <string.h>
  35. #define MAX 256
  36. #define SS struct sockaddr
  37.  
  38.  
  39. int main(int argc, char *argv[])
  40. {
  41. int socks, start, stop, i;
  42. struct hostent *bounce;
  43. struct sockaddr_in proxey;
  44. char temp[MAX+1];
  45. char buffer[MAX+1];
  46. char connected[]="200"; 
  47. /* Some proxys return a diffrent string, but this is the
  48.    generic HTTP 200 OK check */
  49.  
  50. char conn[]="GET http://";
  51. /* Depending on the type of proxy you connect to, 
  52.    this will be different until the RFC is standardized. 
  53.    It has to be something like GET, or POST or CONNECT 
  54.    depending on the type of proxy box */
  55.  
  56. int port;
  57. char **target;
  58. target=&argv[3];
  59.  
  60. printf("\nProxy Port Scanner v1.2");
  61. printf("\nby Bronc Buster of LoU\n\n");
  62.  
  63. if(argc<5)
  64.   exit(printf("Usage: %s <proxey><port><target><start_port><stop_port>\n",argv[0]));
  65.  
  66. /* get IP of proxy */
  67. bounce=gethostbyname(argv[1]);
  68.   if(!bounce) exit(printf("Domain lookup error\n"));
  69.  
  70. proxey.sin_family=AF_INET;
  71. proxey.sin_addr.s_addr=*(long *)(bounce->h_addr);
  72.  
  73. /* set ports to start and stop at */
  74. start=atoi(argv[4]);
  75. stop=atoi(argv[5]); 
  76.  
  77. /* loop to scan our ports */
  78. for(i=start;i<=stop;i++)
  79.   {
  80. /* create socket */
  81.   proxey.sin_port=htons(atoi(argv[2]));
  82.   socks=socket(AF_INET,SOCK_STREAM,0);
  83.     if(socks<0) exit(printf("Socket error\n"));
  84.   port=i;
  85.  
  86. /* format the string we want to send - it takes to returns for it
  87.    to accept it */
  88.  
  89. sprintf(temp, "%s %s /: %d HTTP/1.0 \n\n",conn,target,port);                          
  90.  
  91. /* connect, send string and read back reply */
  92.   if((connect(socks,(struct sockaddr *) &proxey, sizeof(proxey)))<0)
  93.     exit(printf("Connection error\n"));
  94.   write(socks,temp,strlen(temp));
  95.  
  96.   if(read(socks,buffer,sizeof(buffer))<0)
  97.     exit(printf("Read error"));
  98.  
  99.   if(strcmp(buffer,connected)<=0)
  100.     printf("\nPort: %i open",&i);
  101.  
  102. /* close socket and loop back */
  103.   close(socks);
  104.   }
  105. printf("\nScan finished\n");
  106.  
  107. return 0;
  108. }
  109.  
  110. /* EOF */
  111.